package com.huawei.hianalytics.ab.bc.kl;

import android.util.Pair;
import com.huawei.hianalytics.ab.bc.ef.ab;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import org.json.JSONException;
import org.json.JSONObject;

public abstract class ef {
    public static long ab(String str, long j) {
        long j2 = 0;
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str, Locale.getDefault());
            j2 = simpleDateFormat.parse(simpleDateFormat.format(Long.valueOf(j))).getTime();
        } catch (ParseException e) {
            ab.cd("hmsSdk/stringUtil", "getMillisOfDate(): Time conversion Exception !");
        }
        return j2;
    }

    public static Pair<String, String> ab(String str) {
        if ("_default_config_tag".equals(str)) {
            return new Pair(str, "");
        }
        Object obj;
        Object substring;
        String[] split = str.split("-");
        if (split.length > 2) {
            obj = split[split.length - 1];
            substring = str.substring(0, (str.length() - obj.length()) - 1);
        } else {
            substring = split[0];
            obj = split[1];
        }
        return new Pair(substring, obj);
    }

    public static String ab(int i) {
        switch (i) {
            case 0:
                return "oper";
            case 1:
                return "maint";
            case 2:
                return "preins";
            case 3:
                return "diffprivacy";
            default:
                return "alltype";
        }
    }

    public static String ab(String str, String str2) {
        return "_default_config_tag".equals(str) ? str : str + "-" + str2;
    }

    public static String ab(String str, String str2, String str3) {
        return "_default_config_tag".equals(str) ? "_default_config_tag#" + str3 : str + "-" + str2 + "#" + str3;
    }

    public static Set<String> ab(Set<String> set) {
        if (set == null || set.size() == 0) {
            return new HashSet();
        }
        Set<String> hashSet = new HashSet();
        for (String str : set) {
            String str2;
            if ("_default_config_tag".equals(str2)) {
                hashSet.add("_default_config_tag");
            } else {
                String str3 = str2 + "-" + "oper";
                String str4 = str2 + "-" + "maint";
                str2 = str2 + "-" + "diffprivacy";
                hashSet.add(str3);
                hashSet.add(str4);
                hashSet.add(str2);
            }
        }
        return hashSet;
    }

    public static JSONObject ab(JSONObject jSONObject, String str, String str2, String str3) {
        if (jSONObject == null) {
            jSONObject = new JSONObject();
        }
        try {
            if ("OnPause".equals(str3)) {
                jSONObject.put("_event_duration", str2);
            }
            jSONObject.put("_activity_name", str);
        } catch (JSONException e) {
            ab.cd("hmsSdk/stringUtil", "getEventContent(): JSONException");
        }
        return jSONObject;
    }
}
